package cheme.ProcessEditor.Parts.Factory;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;

import cheme.ProcessEditor.Parts.AnnotationPart;
import cheme.ProcessEditor.Parts.HeatExchangerNoSourcePart;
import cheme.ProcessEditor.Parts.HeatExchangerWithSourcePart;
import cheme.ProcessEditor.Parts.MixerPart;
import cheme.ProcessEditor.Parts.ProcessModelPart;
import cheme.ProcessEditor.Parts.ProcessUnitPart;
import cheme.ProcessEditor.Parts.SeparatorPart;
import cheme.ProcessEditor.Parts.SplitJoinPart;
import cheme.ProcessEditor.Parts.SubprocessPart;
import cheme.ProcessEditor.Parts.TerminalSinkPart;
import cheme.ProcessEditor.Parts.TerminalSourcePart;
import cheme.ProcessEditor.Parts.ToolTipPart;
import cheme.ProcessEditor.Parts.ConsoleView.ContentsEditPart;
import cheme.ProcessEditor.Parts.ConsoleView.HelloEditPart;
import cheme.ProcessEditor.Parts.ConsoleView.PartConsoleView;
import cheme.ProcessEditor.Parts.Equations.PartEquation;
import cheme.ProcessEditor.Parts.Equations.PartEquationField;
import cheme.ProcessEditor.Parts.Equations.PartEquationList;
import cheme.ProcessEditor.Parts.Equations.PartEquationPalette;
import cheme.ProcessEditor.Parts.Equations.PartEquationPaletteField;
import cheme.ProcessEditor.Parts.Equations.PartEquations;
import cheme.ProcessEditor.Parts.Equations.PartOperatorField;
import cheme.ProcessEditor.Parts.SolvabilityStatus.PartSolvabilityStatus;
import cheme.ProcessEditor.Parts.Streams.DirectedStreamPart;
import cheme.ProcessEditor.Parts.Streams.Tag.PartHeatCapacityField;
import cheme.ProcessEditor.Parts.Streams.Tag.PartHeatUnitsField;
import cheme.ProcessEditor.Parts.Streams.Tag.PartImmutableField;
import cheme.ProcessEditor.Parts.Streams.Tag.PartLabelField;
import cheme.ProcessEditor.Parts.Streams.Tag.PartLatentHeatCapacityField;
import cheme.ProcessEditor.Parts.Streams.Tag.PartMaterialField;
import cheme.ProcessEditor.Parts.Streams.Tag.PartOverallTagComponent;
import cheme.ProcessEditor.Parts.Streams.Tag.PartQuantityField;
import cheme.ProcessEditor.Parts.Streams.Tag.PartTag;
import cheme.ProcessEditor.Parts.Streams.Tag.PartTagComponent;
import cheme.ProcessEditor.Parts.Streams.Tag.PartTagComponentList;
import cheme.ProcessEditor.Parts.Streams.Tag.PartUnitsField;
import cheme.ProcessModel.ConsoleView;
import cheme.ProcessModel.ContentsModel;
import cheme.ProcessModel.HelloModel;
import cheme.ProcessModel.IProcessModel;
import cheme.ProcessModel.SolvabilityStatus;
import cheme.ProcessModel.TooltipModel;
import cheme.ProcessModel.Annotations.IAnnotation;
import cheme.ProcessModel.Equations.Equation;
import cheme.ProcessModel.Equations.EquationField;
import cheme.ProcessModel.Equations.EquationList;
import cheme.ProcessModel.Equations.EquationPalette;
import cheme.ProcessModel.Equations.EquationPaletteField;
import cheme.ProcessModel.Equations.Equations;
import cheme.ProcessModel.Equations.OperatorField;
import cheme.ProcessModel.ProcessUnits.HeatExchangerNoSource;
import cheme.ProcessModel.ProcessUnits.HeatExchangerWithSource;
import cheme.ProcessModel.ProcessUnits.IProcessUnit;
import cheme.ProcessModel.ProcessUnits.ITerminalSink;
import cheme.ProcessModel.ProcessUnits.ITerminalSource;
import cheme.ProcessModel.ProcessUnits.Mixer;
import cheme.ProcessModel.ProcessUnits.Separator;
import cheme.ProcessModel.ProcessUnits.SplitJoin;
import cheme.ProcessModel.ProcessUnits.Streams.HeatExchangerStream;
import cheme.ProcessModel.ProcessUnits.Streams.Stream;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.AbstractUnitsField;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.HeatCapacityField;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.HeatUnitsField;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.LabelField;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.LatentHeatCapacityField;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.MaterialField;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.OverallTagComponent;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.OverallUnitsField;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.QuantityField;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.Tag;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.TagComponent;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.TagComponentList;
import cheme.ProcessModel.Subprocess.Subprocess;
import cheme.ProcessModel.Table.ImmutableField;

public class EditpartFactory implements EditPartFactory
{
	public EditPart createEditPart(EditPart context, Object model)
	{
		EditPart part = null;

		/*
		 * Decide which model we have, and which editpart to create and manage it.
		 */
		if(model instanceof IAnnotation)
		{
			part = new AnnotationPart();
		}
		else if(model instanceof IProcessModel)
		{
			part = new ProcessModelPart();
		}
		else if(model instanceof Subprocess)
		{
			//part = new SubprocessPart();
		}
		else if(model instanceof ITerminalSink)
		{
			part = new TerminalSinkPart();
		}
		else if(model instanceof ITerminalSource)
		{
			part = new TerminalSourcePart();
		}
		else if(model instanceof Mixer)
		{
			part = new MixerPart();
		}
		else if(model instanceof Separator)
		{
			part = new SeparatorPart();
		}
		else if(model instanceof SplitJoin)
		{
			//part = new SplitJoinPart();
		}
		else if(model instanceof HeatExchangerWithSource)
		{
			part = new HeatExchangerWithSourcePart();
		}
		else if(model instanceof HeatExchangerNoSource)
		{
			part = new HeatExchangerNoSourcePart();
		}
		else if(model instanceof IProcessUnit)
		{
			part = new ProcessUnitPart();
		}
		else if(model instanceof Stream)
		{
			part = new DirectedStreamPart();
		}
		else if(model instanceof HeatExchangerStream)
		{
			part = new DirectedStreamPart();
		}
		else if(model instanceof Tag)
		{
			part = new PartTag();  
		}
		else if(model instanceof TagComponentList)
		{
			part = new PartTagComponentList();
		}
		else if(model instanceof OverallTagComponent)
		{
			part = new PartOverallTagComponent();
		}
		else if(model instanceof OverallUnitsField)
		{
			part = new PartUnitsField();
		}
		else if(model instanceof HeatUnitsField)
		{
			part = new PartHeatUnitsField(); 
		}
		else if(model instanceof TagComponent)
		{
			part = new PartTagComponent();
		}
		else if(model instanceof ImmutableField)
		{
			part = new PartImmutableField();
		}
		else if(model instanceof EquationField)
		{
			part = new PartEquationField();
		}
		else if(model instanceof LabelField)
		{
			part = new PartLabelField();
		}
		else if(model instanceof HeatCapacityField)
		{
			part = new PartHeatCapacityField();
		}
		else if(model instanceof LatentHeatCapacityField)
		{
			part = new PartLatentHeatCapacityField();
		}
		else if(model instanceof QuantityField)
		{
			part = new PartQuantityField();
		}
		else if(model instanceof AbstractUnitsField)
		{
			part = new PartUnitsField();
		}
		else if(model instanceof MaterialField)
		{
			part = new PartMaterialField();
		}
		else if(model instanceof OperatorField)
		{
			part = new PartOperatorField();
		}
		else if(model instanceof EquationPaletteField)
		{
			part = new PartEquationPaletteField();
		}
		else if(model instanceof Equations)
		{
			part = new PartEquations();
		}
		else if(model instanceof EquationList)
		{
			part = new PartEquationList();
		}
		else if(model instanceof EquationPalette)
		{
			part = new PartEquationPalette();
		}
		else if(model instanceof Equation)
		{
			part = new PartEquation();
		}
		else if (model instanceof SolvabilityStatus)
		{
			part = new PartSolvabilityStatus();	
		}
		else if (model instanceof ConsoleView)
		{
			part = new PartConsoleView();	
		}
		else if (model instanceof TooltipModel)
		{
			part = new ToolTipPart();
		}
		
		       

	
	
		try
		{
			/*
			 * Tell the part about it's model. This can be used to create the Figure
			 * based representation at runtime.
			 */
			part.setModel(model);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}

		return part;
	}
}
